package atmgui;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class MenuPanel extends JPanel implements ActionListener {
    private ATM05 atm05;
    private JButton searchBtn = new JButton(new ImageIcon("src\\images\\buttonFind.jpg"));
    private JButton saveBtn = new JButton(new ImageIcon("src\\images\\buttonSave.jpg"));
    //存钱
    private JButton getBtn = new JButton(new ImageIcon("src/images/buttonGet.jpg"));
    //取钱
    private JButton modifyBtn = new JButton(new ImageIcon("src/images/buttonModify.jpg"));
    //修改密码
    private JButton offBtn = new JButton(new ImageIcon("src/images/buttonOff.jpg"));
    private  JButton transfer=new JButton(new ImageIcon("src/images/pane.jpg"));


    //退出
    public MenuPanel(ATM05 atm05) {
        this.atm05 = atm05;
        this.setLayout(null);
        this.setOpaque(false);

        searchBtn.setBounds(0, 100, 140, 50);
        searchBtn.addActionListener(this);
        this.add(searchBtn);

        saveBtn.setBounds(0, 300, 140, 50);
        saveBtn.addActionListener(this);
        this.add(saveBtn);

        getBtn.setBounds(0, 500, 140, 50);
        getBtn.addActionListener(this);
        this.add(getBtn);

        modifyBtn.setBounds(880, 100, 140, 50);
        modifyBtn.addActionListener(this);
        this.add(modifyBtn);

        transfer.setBounds(880,300,140,50);
        transfer.addActionListener(this);
        this.add(transfer);
        JLabel label=new JLabel("转账");
        label.setBounds(880,300,100,50);


        offBtn.setBounds(880, 500, 140, 50);
        offBtn.addActionListener(this);
        this.add(offBtn);


    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if (saveBtn == e.getSource()) {
            atm05.showPanel("save");
        } else if (getBtn == e.getSource()) {
            atm05.showPanel("get");

        } else if (searchBtn == e.getSource()) {
            atm05.showPanel("search");
        }
        else if (offBtn==e.getSource()) {
            System.exit(0);
        }else if (transfer==e.getSource()){
            atm05.showPanel("transfer");
        }else if (modifyBtn==e.getSource()){
            atm05.showPanel("changePwd");
        }
    }
}
